/* 公共方法封装 */
var base = require('../../assets/js/base.js')
var md5 = require('../../assets/js/md5.js') 
const encryption = {
  /**
   * 将对象解析成url字符串
   * @param {String} obj 参数对象
   * @param {Boolean} unEncodeURI 不使用编码
   */
  param(salt, jsonString) {
    // var salt = "yl9ekx";
    // var simpleObject = new Object();
    // simpleObject["age"] = 12;
    // simpleObject["name"] = "ffff";
    // simpleObject["tips"] = "code";
    // simpleObject["user"] = "stylefeng";
    // var jsonString = JSON.stringify(simpleObject);
    // console.log(jsonString);
    var encode = base.Base64(jsonString);
    var hash = md5.hexMD5(encode + salt);
    var baseTransferEntity = new Object();
    baseTransferEntity["base"] = encode;
    baseTransferEntity["sign"] = hash;
    console.log(JSON.stringify(baseTransferEntity));
    return JSON.stringify(baseTransferEntity);
  }
};

module.exports = encryption;